<!DOCTYPE html>
<html lang="en">
<body>
<meta charset="UTF-8">
<meta content="width=device-width,initial-scale=1,user-scalable=0" name="viewport">
<title>个人中心</title>
<link href="../../public/plugin/weui/weui.min.css" rel="stylesheet">
<link href="../../public/plugin/jquery-weui/css/jquery-weui.min.css" rel="stylesheet">
<link href="../../public/plugin/vant/index.css" rel="stylesheet">
<link href="../../public/css/common.css?v=20230529" rel="stylesheet">
<style>
    #app {
        background-color: white;
        overflow-x: hidden;
    }

    .info-wrapper .avatar, .info-wrapper .member-code {
        height: 80px;
        line-height: 80px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .info-wrapper {
        padding-top: 5px;
        height: 160px;
        max-height: 160px;
        background-image: url("../../public/image/background/member-center.png");
        background-size: 100% 100%;
        border-bottom-left-radius: 8px;
        border-bottom-right-radius: 8px;
        margin: 0 1px;
    }

    .info-wrapper .avatar, .info-wrapper .member-code {
        height: 80px;
        line-height: 80px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .info-wrapper .avatar img {
        width: 70px;
        height: 70px;
        border-radius: 10%;
    }

    .info-wrapper .member-code img {
        width: 30px;
        height: 30px;
    }

    .info-wrapper .member-info {
        height: 80px;
        display: flex;
        justify-content: center;
        flex-direction: column;
    }

    .member-info .member-name {
        font-weight: bold;
        color: #fefefe;
        margin-bottom: 10px;
    }

    .function-item {
        height: 80px;
        max-height: 80px;
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        color: white;
        font-size: 18px;
    }

    .member-info .member-detail {
        font-size: 14px;
        color: #fefefe;
    }

    .main-color {
        background-color: #FBFBFD;
    }

    .function-item .top {
        height: 40px;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-weight: bold;
        color: rgb(35, 71, 107);
    }

    .function-item .sum-desc {
        color: rgb(35, 71, 107);
        font-size: 15px;
        font-weight: bold;
        height: 20px;
    }

    .weui-cell img {
        width: 25px;
        height: 25px;
    }

    .member-level {

    }

    .member-level img {
        width: 18px;
        margin-right: 5px;
    }

    .member-level .top {
        font-weight: 700;
        font-size: 16px;
        color: #fefefe;
        height: 35px;
        display: flex;
        justify-content: start;
        align-items: center;

    }

    .member-level .bottom {
        color: #fefefe;
        height: 45px;
        display: flex;
        justify-content: start;
        align-items: center;
    }

    .grid-title {
        padding-top: 10px;
        padding-left: 10px;
        font-size: 16px;
    }

    .grid-item img {
        width: 30px;
        height: auto;
    }

    h3 {
        color: rgba(255, 255, 251, 1);
        margin-top: 8px;
        line-height: 45px;
        font-size: 1em;
        height: 35px;
    }

    .grid-wrapper {
        margin: 1px;
    }

    .van-grid-item {
        position: relative;
        box-sizing: border-box;
        height: 100px;
    }

    .van-image {
        position: relative;
        display: inline-block;
        left: 23%;
    }

    .name {
        font-weight: 600;
        text-align: center;
    }

</style>

<div id="app" v-cloak>
    <div class="banner">
        <van-swipe :autoplay="3000" class="my-swipe" indicator-color="white">
            <van-swipe-item v-for="item in bannerList">
                <img :src="item.imgUrl" alt="">
            </van-swipe-item>
        </van-swipe>
    </div>
    <div class="main-color">
        <div class="info-wrapper">
            <van-row>
                <van-col span="6">
                    <!--微信用户头像-->
                    <div class="avatar">
                        <img :src="userInfo ? userInfo.headImgUrl : ''" alt="">
                    </div>
                </van-col>
                <van-col span="12">
                    <!--昵称和电话-->
                    <div class="member-info">
                        <div class="member-name">{{ userInfo ? userInfo.nickname : '' }}</div>
                        <div class="member-detail">{{ memberInfo ? memberInfo.phone : '' }}</div>
                    </div>
                </van-col>
                <van-col span="6">
                    <!-- 会员等级信息-->
                    <div class="member-level">
                        <div class="top"><img alt=""
                                              src="../../public/image/icon/score-c.svg">{{level}}
                        </div>
                        <div @click="showWaitForMe" class="bottom">我的特权
                            <van-icon name="arrow"></van-icon>
                        </div>
                    </div>
                </van-col>
            </van-row>
            <!--统计数据-->
            <div class="weui-flex" style="text-align: center;">
                <div @click="openPage('../member/point.html')" class="weui-flex__item function-item">
                    <div class="top">{{memberInfo.totalPoints}}</div>
                    <div class="sum-desc">积分</div>
                </div>
                <div @click="openPage('../coupon/index.html')" class="weui-flex__item function-item">
                    <div class="top">{{ couponList.length }}</div>
                    <div class="sum-desc">优惠券</div>
                </div>
                <div @click="openPage('./code.html')" class="weui-flex__item function-item">
                    <div class="member-code top">
                        <img alt="" src="../../public/image/icon/qr.svg">
                    </div>
                    <div class="sum-desc">VIP码</div>
                </div>
            </div>
        </div>
        <div class="grid-title">我的服务</div>
        <div class="grid-wrapper">
            <van-grid :border="false" :column-num="3" :gutter="10" square>
                <van-grid-item @click="openPage('../card/master.html')">
                    <div class="grid-item">
                        <van-image fit="contain" src="../../public/image/icon/card.png"></van-image>
                        <div class="name">VIP卡</div>
                    </div>
                </van-grid-item>
                <van-grid-item @click="openPage('../member/signIn.html')">
                    <div class="grid-item">
                        <van-image fit="contain" src="../../public/image/icon/signIn.png"></van-image>
                        <div class="name">打卡签到</div>
                    </div>
                </van-grid-item>
                <van-grid-item @click="openPage('../store/mall.html')">
                    <div class="grid-item">
                        <van-image fit="contain" src="../../public/image/icon/shopping.png"></van-image>
                        <div class="name">线上商城</div>
                    </div>
                </van-grid-item>
            </van-grid>
            <van-grid :border="false" :column-num="3" :gutter="10" square>
                <van-grid-item @click="openPage('../card/list.html')"></van-grid-item>
                <van-grid-item @click="openPage('../card/list.html')"></van-grid-item>
                <van-grid-item @click="openPage('../card/list.html')"></van-grid-item>
            </van-grid>
            <van-grid :border="false" :column-num="3" :gutter="10" square>
                <van-grid-item @click="openPage('../card/list.html')"></van-grid-item>
                <van-grid-item @click="openPage('../card/list.html')"></van-grid-item>
                <van-grid-item @click="openPage('../card/list.html')"></van-grid-item>
            </van-grid>
        </div>
        <!-- 底部文字  -->
        <div class="weui-msg__extra-area">
            <div class="weui-footer">
                <p class="weui-footer__text">星火科技有限公司提供技术支持</p>
            </div>
        </div>
    </div>
</div>

<script src="../../public/plugin/jquery/jquery.min.js" type="text/javascript"></script>
<script src="../../public/plugin/jquery-weui/js/jquery-weui.min.js" type="text/javascript"></script>
<script src="../../public/plugin/jquery-weui/js/swiper.min.js" type="text/javascript"></script>
<script src="../../public/plugin/vue/vue.min.js" type="text/javascript"></script>
<script src="../../public/plugin/qrcodejs/qrcode.min.js" type="text/javascript"></script>
<script src="../../public/plugin/vant/vant.min.js" type="text/javascript"></script>
<script src="../../public/js/common.js?v=20230420190021" type="text/javascript"></script>

<script>
    new Vue({
        el: "#app",
        data: {
            bannerList: [
                {imgUrl: '../../public/image/banner/banner1.png'},
                {imgUrl: '../../public/image/banner/banner2.png'},
                {imgUrl: '../../public/image/banner/banner3.png'}
            ],
            userInfo: {},
            memberInfo: {},
            couponList: []
        },
        computed: {
            level() {
                if (this.memberInfo.totalPoints < 500) {
                    return '童生';
                } else if (this.memberInfo.totalPoints < 1000) {
                    return '举人';
                } else if (this.memberInfo.totalPoints < 2000) {
                    return '进士';
                } else if (this.memberInfo.totalPoints < 5000) {
                    return '状元';
                } else {
                    return '文曲星下凡';
                }
            }
        },
        mounted: function () {
            let self = this;
            MemberUtils.getUserInfo().then(function (res) {
                console.log(res);
                if (res && res.code === 200) {
                    self.userInfo = res.data;
                } else {
                    oAuth2UserInfo();
                }
            })
            MemberUtils.getMemberInfo().then(function (res) {
                console.log(res);
                if (res && res.code === 200) {
                    self.memberInfo = res.data;
                    setCookie(COOKIE_MEMBER_ID, self.memberInfo.id, 30);
                    // 获取会员优惠券
                    MemberUtils.getCouponInfo(self.memberInfo.id).then(function (res) {
                        if (res && res.code === 200) {
                            console.log("会员优惠券统计");
                            console.log(res);
                            self.couponList = res.data;
                        }
                    })
                } else {
                    oAuth2UserInfo();
                }
            });
        },
        methods: {
            // 打开新页面
            openPage: function (url) {
                window.location.href = url;
            },
            showWaitForMe: function () {
                $.alert("正在骑马赶来的路上！");
            }
        }
    })
</script>
</body>
</html>
